<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title></title>
</head>
<style>
  #main {
    display: flex;
    justify-content: center;
    height: 280px;
    align-items: center;
    font-size: 28px;
  }

  .mac-css {
    height: 30px;
    width: 266px;
    font-size: 26px;
    color: blue;
    border: none;
  }

  button {
    height: 30px;
    width: 75px;
  }

  .titleText {
    color: red;
  }
</style>

<body>
  <div id="main">
    <span class="titleText">授权码：</span>
    <input class="mac-css" id="mac_id" readonly="readonly" />
    &nbsp;<button class="" onclick="copy()">复制</button>
  </div>
</body>
<script>
  import {
    macCode
  } from './mac.js';
  document.getElementById('mac_id').value = macCode;

  function copy() {
    var macid = document.getElementById("mac_id");
    if (macid.value) {
      macid.select(); // 选择对象
      document.execCommand("Copy"); // 执行浏览器复制命令
      alert("已复制好，可贴粘！");
    }
  }
</script>

</html>